﻿using Org.BouncyCastle.Crypto;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Zocono.WCS.Domain.DomainRepository;
using Zocono.WCS.Domain.EntityInfo;
using Zocono.WMS.Infrastructure.BaseRepository;

namespace Zocono.WCS.Infrastructure.Repository
{
    public class RunLogRepository: BaseRepository<RunLogInfo>, IRunLogRepository
    {
        public RunLogRepository(SqlSugarClient context=null):base(context)
        {
            
        }
        //新增加，可删除
        //public Task<RunLogInfo> FindByContentAsync(string runLog)
        //{
        //    throw new NotImplementedException();
        //}
        private readonly SqlSugarClient _db;


        public async Task<RunLogInfo> FindByContentAsync(string runLog, string equipmentCode)
        {
            // 获取已经连接的SqlSugarClient对象
            var db = new SqlSugarClient(new ConnectionConfig
            {
                // 设置已经连接的SqlSugarClient对象的连接字符串和数据库类型
                ConnectionString = "Data Source=192.168.60.245;Initial Catalog=ZJNWCS21068;User Id=sa;Password=1@admin;MultipleActiveResultSets=true",
                DbType = DbType.SqlServer // 根据实际情况选择数据库类型
            });

            // 然后，使用 db 对象的 Queryable 方法查询满足条件的日志信息
            return await db.Queryable<RunLogInfo>()
                .Where(o => o.RunLog == runLog && o.EquipmentCode == equipmentCode)
                .FirstAsync();


        }

       
    }
}
